﻿using System;
using System.Collections.Generic;
using System.Text;
using Castle.ActiveRecord;
using Castle.Components.Validator;
using MiragePWF.NH.Validation;
using Wolfut.MirageEE.Kernal.Common;

namespace Wolfut.MirageEE.Domain.Sales
{
    /// <summary>
    /// 销售单信息
    /// </summary>
    /// <remarks>
    /// Author: Leo
    /// Date: 2009-03-14
    /// </remarks>
    [ActiveRecord("SALES_BILLS")]
    public class SalesBill : PersistentObjectWithGuid
    {
        #region 销售单编号
        private string salesBillCode;
        [Property("SALES_BILL_CODE")]
        [ValidateIsUniqueInSameTransactionWithString(false, "数据库已经存在相同的销售单编号！")]
        [ValidateNonEmpty, ValidateLength(0, 100, "销售单编号超长")]
        public virtual string SalesBillCode
        {
            get { return salesBillCode; }
            set { salesBillCode = value; }
        }
        #endregion

        #region 日期
        private DateTime salesBillDate = DateTime.Now;
        [Property("SALES_BILL_DATE")]
        [ValidateNonEmpty]
        public virtual DateTime SalesBillDate
        {
            get { return salesBillDate; }
            set { salesBillDate = value; }
        }
        #endregion

        #region 销售人员
        private string salesMan = string.Empty;
        [Property("SALESMAN")]
        [ValidateNonEmpty, ValidateLength(0, 100, "销售单编号超长")]
        public virtual string SalesMan
        {
            get { return salesMan; }
            set { salesMan = value; }
        }
        #endregion

        #region 项目ID
        private string projectID = string.Empty;
        [Property("PROJECT_ID")]
        [ValidateNonEmpty, ValidateLength(0, 40, "项目ID超长")]
        public virtual string ProjectID
        {
            get { return projectID; }
            set { projectID = value; }
        }
        #endregion

        #region 币别代码
        private string currencyCode = string.Empty;
        [Property("CURRENCY_CODE")]
        [ValidateNonEmpty, ValidateLength(0, 20, "币别代码超长")]
        public virtual string CurrencyCode
        {
            get { return currencyCode; }
            set { currencyCode = value; }
        }
        #endregion

        #region 送货单号
        private string deliverBillCode = string.Empty;
        [Property("DELIVER_GOODS_BILL_CODE")]
        [ValidateNonEmpty, ValidateLength(0, 100, "送货单号超长")]
        public virtual string DeliverBillCode
        {
            get { return deliverBillCode; }
            set { deliverBillCode = value; }
        }
        #endregion

        #region 销售订单ID
        private string salesOrderID = string.Empty;
        [Property("SALES_ORDER_ID")]
        [ValidateNonEmpty, ValidateLength(0, 40, "销售订单ID超长")]
        public virtual string SalesOrderID
        {
            get { return salesOrderID; }
            set { salesOrderID = value; }
        }

        #endregion

        #region 客户订单号（销售订单号）
        private string customerOrderCode = string.Empty;
        [Property("CUSTOMER_ORDER_CODE")]
        [ValidateNonEmpty, ValidateLength(0, 100, "客户订单号（销售订单号）超长")]
        public virtual string CustomerOrderCode
        {
            get { return customerOrderCode; }
            set { customerOrderCode = value; }
        }
        #endregion

        #region 客户发票号
        private string customerInvoiceNumber = string.Empty;
        [Property("CUSTOMER_INVOICE_NUMBER")]
        [ValidateNonEmpty, ValidateLength(0, 50, "客户发票号超长")]
        public virtual string CustomerInvoiceNumber
        {
            get { return customerInvoiceNumber; }
            set { customerInvoiceNumber = value; }
        }
        #endregion

        #region 开票类型
        private short invoiceType;
        [Property("INVOICE_TYPE")]
        public virtual short InvoiceType
        {
            get { return invoiceType; }
            set { invoiceType = value; }
        }
        #endregion

        #region 客户ID
        private string customerID = string.Empty;
        [Property("CUSTOMER_ID")]
        [ValidateNonEmpty, ValidateLength(0, 40, "客户ID超长")]
        public virtual string CustomerID
        {
            get { return customerID; }
            set { customerID = value; }
        }
        #endregion

        #region 备注
        private string remarks = string.Empty;
        [Property("REMARKS")]
        [ValidateNonEmpty, ValidateLength(0, 2000, "备注超长")]
        public virtual string Remarks
        {
            get { return remarks; }
            set { remarks = value; }
        }
        #endregion

        #region 送货日期
        private DateTime deliveryDate;
        [Property("DELIVER_GOODS_DATE")]
        public virtual DateTime DeliveryDate
        {
            get { return deliveryDate; }
            set { deliveryDate = value; }
        }
        #endregion

        #region 送货地址
        private string deliveryAddress = string.Empty;
        [Property("DELIVER_GOODS_ADDRESS")]
        [ValidateNonEmpty, ValidateLength(0, 510, "送货地址超长")]
        public virtual string DeliveryAddress
        {
            get { return deliveryAddress; }
            set { deliveryAddress = value; }
        }
        #endregion

        #region 付款状态
        private short paymentState;
        [Property("PAYMENT_STATE")]
        [ValidateNonEmpty]
        public virtual short PaymentState
        {
            get { return paymentState; }
            set { paymentState = value; }
        }
        #endregion

        #region 优惠
        private decimal discount;
        [Property("DISCOUNT")]
        public virtual decimal Discount
        {
            get { return discount; }
            set { discount = value; }
        }
        #endregion

        #region 收款帐户
        private string collectingBillAccount = string.Empty;
        [Property("COLLECTING_BILL_ACCOUNT")]
        [ValidateNonEmpty, ValidateLength(0, 100, "收款帐户超长")]
        public virtual string CollectingBillAccount
        {
            get { return collectingBillAccount; }
            set { collectingBillAccount = value; }
        }
        #endregion

        #region 本次收款金额
        private decimal currentCollectingBillSum;
        [Property("CURRENT_COLLECTING_BILL_SUM")]
        public virtual decimal CurrentCollectingBillSum
        {
            get { return currentCollectingBillSum; }
            set { currentCollectingBillSum = value; }
        }
        #endregion

        #region 账期
        private short collectionPeriod;
        [Property("COLLECTION_PERIOD")]
        public virtual short CollectionPeriod
        {
            get { return collectionPeriod; }
            set { collectionPeriod = value; }
        }
        #endregion

        #region 制单人
        private string producerBy = string.Empty;
        [Property("PRODUCER_BY")]
        [ValidateNonEmpty, ValidateLength(0, 40, "制单人超长")]
        public virtual string ProducerBy
        {
            get { return producerBy; }
            set { producerBy = value; }
        }
        #endregion

        #region 销售订单号
        private string salesOrderCode = string.Empty;
        [Property("SELL_ORDER_CODE")]
        [ValidateNonEmpty, ValidateLength(0, 100, "销售订单号超长")]
        public virtual string SalesOrderCode
        {
            get { return salesOrderCode; }
            set { salesOrderCode = value; }
        }
        #endregion

        #region 是否删除
        private bool isDeleted;
        [Property("IS_DELETED")]
        [ValidateNonEmpty]
        public virtual bool IsDeleted
        {
            get { return isDeleted; }
            set { isDeleted = value; }
        }
        #endregion
    }
}
